package com.bytedance.common.utility.reflect;

import android.util.Log;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public final class JavaCalls {
    public final class a$a {
        public final Class a;
        public final Object b;

        public a$a(Class a, Object b) {
            this.a = a;
            this.b = b;
        }
    }

    private static final Map a;

    static {
        HashMap v0 = new HashMap();
        a = ((Map)v0);
        ((Map)v0).put(Boolean.class, Boolean.TYPE);
        a.put(Byte.class, Byte.TYPE);
        a.put(Character.class, Character.TYPE);
        a.put(Short.class, Short.TYPE);
        a.put(Integer.class, Integer.TYPE);
        a.put(Float.class, Float.TYPE);
        a.put(Long.class, Long.TYPE);
        a.put(Double.class, Double.TYPE);
        a.put(Boolean.TYPE, Boolean.TYPE);
        a.put(Byte.TYPE, Byte.TYPE);
        a.put(Character.TYPE, Character.TYPE);
        a.put(Short.TYPE, Short.TYPE);
        a.put(Integer.TYPE, Integer.TYPE);
        a.put(Float.TYPE, Float.TYPE);
        a.put(Long.TYPE, Long.TYPE);
        a.put(Double.TYPE, Double.TYPE);
    }

    public static Object a(String arg10, String arg11, Object[] arg12) {
        Method v3_2 = null;
        Class[] v6;
        int v4;
        Class v0_2;
        Object v0_1;
        int v2 = 0;
        Class v1 = null;
        int v9 = 3;
        try {
            Class v3 = Class.forName(arg10);
            Class[] v7 = new Class[3];
            int v5;
            for(v5 = 0; v5 < v9; ++v5) {
                v0_1 = arg12[v5];
                if(v0_1 != null && ((v0_1 instanceof a$a))) {
                    v0_2 = ((a$a)v0_1).a;
                    v4 = v5;
                    v6 = v7;
                }
                else if(v0_1 == null) {
                    v0_2 = v1;
                    v4 = v5;
                    v6 = v7;
                }
                else {
                    v0_2 = v0_1.getClass();
                    v4 = v5;
                    v6 = v7;
                }

                v6[v4] = v0_2;
            }

            Class v4_1;
            for(v4_1 = v3; true; v4_1 = v4_1.getSuperclass()) {
                Method[] v5_1 = v4_1.getDeclaredMethods();
                if(arg11 == null) {
                    throw new NullPointerException("Method name must not be null.");
                }

                int v6_1 = v5_1.length;
                int v3_1;
                boolean bingo = false;
                for(v3_1 = 0; v3_1 < v6_1; ++v3_1) {
                    Method v0_3 = v5_1[v3_1];
                    if((v0_3.getName().equals(arg11)) && (a(v0_3.getParameterTypes(), v7))) {
                        v3_2 = v0_3;
                        bingo = true;
                        break;
                    }
                }

                if(bingo){

                }else{
                    v3_2 = ((Method)null);
                }
                if(v3_2 != null) {
                    label_72:
                    v3_2.setAccessible(true);
                    Object v4_2 = null;
                    Object[] v5_2 = new Object[3];
                    while(v2 < v9) {
                        v0_1 = arg12[v2];
                        v5_2[v2] = v0_1 == null || !(v0_1 instanceof a$a) ? v0_1 : ((a$a)v0_1).b;
                        ++v2;
                    }

                    return v3_2.invoke(v4_2, v5_2);
                }

                if(v4_1.getSuperclass() == null) {
                    break;
                }
            }
            throw new NoSuchMethodException();
        }
        catch(Exception v0) {
            Log.w("JavaCalls", "Meet exception when call Method \'" + arg11 + "\' in " + arg10, ((Throwable)v0));
            v0_1 = v1;
        }

        return v0_1;
    }

    private static boolean a(Class[] arg5, Class[] arg6) {
        boolean v2 = false;
        if (arg5 != null && arg5.length == 3) {
            int v1;
            for (v1 = 0; v1 < arg5.length; ++v1) {
                if (!arg5[v1].isAssignableFrom(arg6[v1])) {
                    if (!a.containsKey(arg5[v1])) {
                    } else if (a.get(arg5[v1]).equals(a.get(arg6[v1]))) {
                        continue;
                    }
                    return v2;
                }
            }

            v2 = true;
        }
        return v2;
    }
}

